package com.ivncorp.evnproject.helpers;

import java.io.IOException;

import android.content.Context;
import android.media.ExifInterface;
import android.widget.Toast;
import com.ivncorp.evnproject.R;

public class ExifHelpers {

	public void setExifLocation(String filePath,
			LocationTracker locationTracker, Context context) {
		ExifInterface exif;
		try {
			if (locationTracker != null) {
				exif = new ExifInterface(filePath);
				exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE,
						locationTracker.getLatitude());
				exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF,
						locationTracker.getLatitudeRef());
				exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,
						locationTracker.getLongitude());
				exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF,
						locationTracker.getLongitudeRef());
				exif.saveAttributes();
			}
		} catch (IOException e) {

		}
	}

	public void setExifGPS(String filePath, Context context) {
		ExifInterface exif;
		try {
			Variables variables = new Variables();
			exif = new ExifInterface(filePath);
			if (variables.getLatitude() != null) {
				exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE,
						variables.getLatitude());
				exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF,
						variables.getLatitudeRef());
				exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE,
						variables.getLongitude());
				exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF,
						variables.getLongitudeRef());
				exif.saveAttributes();
			} else {
				Toast.makeText(context, R.string.khong_lay_dc_gps_,
						Toast.LENGTH_SHORT).show();
			}
		} catch (IOException e) {

		}
	}
}
